All Functions Used on PO12Q

knit_hooks

{knitr}

Get or set knitr hook functions for customising output

summary

{base}

Obtain summary statistics or detailed regression output

read_excel

{readxl}

Read an Excel file

geom_point

{GGPLOT2}

Generates a scatter plot

read.csv

{utils}

Read a csv file to data frame. Specify stringsAsFactors = FALSE to keep all string columns as characters

with

{base}

evaluate expression in the context of a data frame

write.csv

{utils}

write a csv file to a data frame

margin

{GGPLOT2}

Set margins around plot elements (used inside theme elements)

replace

{base}

Replace elements in a vector

labs

{GGPLOT2}

Customise labels in GGPLOT2

group_tt

{tinytable}

Grouping in tinytable

as.numeric

{base}

Coerce a vector to numeric

scale_y_continuous

{GGPLOT2}

Customise continuous y axis

rm

{base}

Remove objects

cut

{base}

Convert Numeric to Factor

sapply

{base}

Apply a function over a vector or list and simplify the result

resid

{stats}

Extracts model residuals from objects returned by modeling functions

element_text

{GGPLOT2}

Customise text in GGPLOT2

plot

{graphics}

Generic function from base R to produce a plot

library

{base}

Load an R package

set.seed

{base}

Initialise a pseudorandom number generator.

scale_color_discrete

{GGPLOT2}

Customise the discrete colour scale

pwr.r.test

{pwr}

Power analysis for correlation tests

hatvalues

{stats}

Extract leverage (hat) values from a fitted model

sum

{base}

Get sum of numeric values or a vector

ggsave

{GGPLOT2}

Save a ggplot to file

round

{base}

Rounds numbers

log

{base}

log (default base = e)

ls

{base}

Return a vector of character strings giving the names of the objects in the specified environment

geom_jitter

{GGPLOT2}

Add randomly displaced points to reduce overplotting

plotPlane

{rockchalk}

Draw a 3-D regression plot for two predictors

matrix

{base}

Creates a matrix from the given set of values.

correlation_matrix

{corrtable}

Create a formatted correlation matrix of variables

vdem

{vdemdata}

V-Dem country-year dataset

mean

{base}

Get mean of a vector

c

{base}

Combine values/vectors into a vector

median

{stats}

Get median of a vector

diag

{base}

Extract or construct diagonal elements or matrices

poly

{stats}

Compute orthogonal polynomials (used for polynomial regression)

droplevels

{base}

Drop Unused Levels from Factors

element_blank

{GGPLOT2}

This theme element draws nothing, and assigns no space

summarise

{dplyr}

collapse the dataset to a summary statistic. Usually used with group_by()

dim

{base}

Get dimensions of a data frame

scale_x_continuous

{GGPLOT2}

Customise continuous x axis

resettest

{lmtest}

Ramsey’s RESET test for functional form of a regression model

save_tt

{tinytable}

Save a tinytable object to a file

coord_flip

{GGPLOT2}

Flip the x and y axes of a graph

levels

{base}

Get levels of a factor

complete.cases

{stats}

Find Complete Cases

datasummary

{modelsummary}

Create customizable summary-statistics tables

is.na

{base}

Check if a value is NA/elements of vector are NA

DescTools

{DescTools}

A package of miscellaneous functions for descriptive statistics and basic data analysis

ggplot

{GGPLOT2}

Create a ggplot graph

xlab

{GGPLOT2}

Label the x axis (ggplot)

data.frame

{base}

Create a data.frame from vectors

print

{base}

Print object to the console

abline

{graphics}

Add a straight line to a plot (by intercept/slope, or horizontal/vertical)

filter

{dplyr}

Filter out rows of a data frame according to logical vector

vif

{car}

Calculate Variance Inflation Factor

factor

{base}

Create a factor

pchisq

{stats}

Cumulative distribution function for chi-squared distribution

geom_histogram

{GGPLOT2}

Generates a histogram

group_by

{dplyr}

Group tibble/data.frame by a factor variable. All further tidyverse operations are performed group-wise

t.test

{stats}

Performs one and two sample t-tests on vectors of data.

prop.table

{base}

Transform frequency table into table of proportions

as.factor

{base}

Coerce a vector to factor

ylab

{GGPLOT2}

Label the y axis (ggplot)

nobs

{stats}

Return the number of observations in a model object

fct_relevel

{forcats}

Reorder factor levels by hand

colnames

{base}

Retrieve column names of a data frame

order

{base}

Get indexes that will sort a vector

chisq.test

{stats}

Chi-Squared test (e.g. for cross-tabulations)

ifelse

{base}

Return a or b depending on the value of test

quantile

{stats}

Obtain empirical quantiles of a vector

vcov

{stats}

Extract the variance-covariance matrix from a fitted model

theme_minimal

{GGPLOT2}

A minimalistic theme with no background annotations

table

{base}

Obtain frequency table of a variable/cross-tabulation of two variables

bptest

{lmtest}

Breusch-Pagan Test for Homoscedasticity

geom_vline

{GGPLOT2}

Draws a vertical line

setwd

{base}

Set Working Directory

cor.test

{stats}

Test for Association/Correlation Between Paired Samples

modelsummary

{modelsummary}

Creates regression and data tables

as.integer

{base}

Convert an object to integer values

relevel

{stats}

Set a reference level for a factor variable

as.character

{base}

Coerce a vector to character

theme_classic

{GGPLOT2}

A minimalistic theme with no gridlines

theme

{GGPLOT2}

Customize ggplot themes

sd

{stats}

Get standard deviation of a vector

stat_smooth

{GGPLOT2}

Add a smoothed conditional mean (the stat underlying geom_smooth)

recode

{dplyr}

Recode a variable

sample_frac

{dplyr}

Sample a fraction of observations from a data frame

after_stat

{GGPLOT2}

Control aesthetic evaluation. On the module used for displying percent

subset

{base}

Return subsets of vectors, matrices or data frames which meet conditions.

geom_bar

{GGPLOT2}

Generates a bar chart

vcovHC

{sandwich}

Heteroscedasticity-consistent estimation of the covariance matrix of the coefficient estimates

theme_latex

{tinytable}

A theme for modelsummary/tinytable tables

names

{base}

Get or set names of an object

ggtitle

{GGPLOT2}

Generates a title for a ggplot graph

aes

{GGPLOT2}

Construct aesthetic mapping of a ggplot graph

list

{base}

Create a list object

read_csv

{readr}

Read CSV files

geom_hline

{GGPLOT2}

Add a horizontal line in GGPLOT2

str

{utils}

Get the structure of an R object

predict

{stats}

Generate predicted values from model objects

max

{base}

Get maximum of a vector

lm

{stats}

Fit linear models using least squares

head

{utils}

Show first 5 rows of a data frame

which

{base}

return indexes of TRUE entries of a logical vector

save_plot

{cowplot}

Save a plot to a file

factor

{base}

Create factor variables

mutate

{dplyr}

Create new variables

coeftest

{lmtest}

Inference for Estimated Coefficients

confint

{stats}

Calculate confidence Intervals for Model Parameters

attach

{base}

Attach Set of R Objects to Search Path

reorder

{stats}

Reorder Levels of Factor based on the values of a second variable, usually numeric.

element_line

{GGPLOT2}

Customise line appearance

expression

{base}

Used in plots to add symbols to axes

class

{base}

Retrieve class of an R object

arrange

{dplyr}

Sort values of data frame according to a variable/combination of variables

select

{dplyr}

Select columns from a tibble/data frame

geom_smooth

{GGPLOT2}

Generates a smoothed conditional means curve / line

The end!